﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AVIS.OutBound.WizardAgent
{
    /// <summary>
    /// 订单取消请求
    /// </summary>
    public class CancelOrderRequest : IRequest
    {
        /// <summary>
        /// 订单号，由Wizard接口返回（如：37378367CN5） ReservationNumber
        /// </summary>
        public string OrderNo { get; set; }

        /// <summary>
        /// 用户的姓
        /// </summary>
        public string Surname { get; set; }

        public bool CheckRequest()
        {
            if (string.IsNullOrWhiteSpace(OrderNo))
            {
                throw new WizardException("订单号不能为空！");
            }

            if (string.IsNullOrWhiteSpace(Surname))
            {
                throw new WizardException("用户的姓不能为空！");
            }
            return true;
        }

        public string GetCacheKey()
        {
            return string.Empty;
        }

        public string ToRequestXml()
        {
            var request = this;
            string xmlRequest = string.Format(WizardConsts.OrderCancelXML
                        , request.OrderNo
                        , request.Surname
                    )
                    .Replace("'", "\"")
                    .Replace("OutboundUser", WizardConsts.OutboundUser)
                    .Replace("OutboundPwd", WizardConsts.OutboundPwd)
                    .Replace("OutboundRequestID", WizardConsts.OutboundRequestID);

            return xmlRequest;
        }
    }
}
